
/*
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */


#include <stdio.h>

#include "libmooigraph.h"
#include "lmg.h"

void
lmg_cycles (void)
{
  struct lmgnodel *ptr;
  struct lmgedgel *eptr;
  struct lmgnode *ntmp;
  if (lmgdebug)
    {
      printf ("%s(): start\n", __FUNCTION__);
    }
  lmg_dfs ();
  ptr = lmgnodelist;
  while (ptr)
    {
      ptr->node->bitflags.done = 0;
      ptr = ptr->next;
    }
  eptr = lmgedgelist;
  while (eptr)
    {
      if (eptr->edge->to->tree_layout.level -
	  eptr->edge->from->tree_layout.level <= 0)
	{
	  ntmp = eptr->edge->from;
	  eptr->edge->from = eptr->edge->to;
	  eptr->edge->to = ntmp;
	  eptr->edge->bitflags.reversed = 1;
	}
      eptr = eptr->next;
    }
  if (lmgdebug)
    {
      printf ("%s(): finish\n", __FUNCTION__);
    }
  return;
}

/* End */
